import groovy.io.FileType
import groovy.xml.MarkupBuilder


def TARGET_EXTENSION = '.groovy'
def TEST_DIR = 'd:\\lucky\\lucky\\'
writer = new StringWriter()
builder = new MarkupBuilder(writer)
def timer = new Date().time
builder.files(xmlns: 'http://groovy.codehaus.org') {
        new File(TEST_DIR).eachFileRecurse(FileType.FILES) { analyzedFile ->
            if (analyzedFile.name.contains(TARGET_EXTENSION)) {
                def f = new FileAnalyzer(analyzedFile)
                file(name: analyzedFile.name, path: analyzedFile.absolutePath) {
                    metrics(f.calculateResult())
                }
            }
        }
}
def f = new File("c:\\t.xml")
f.write(writer.toString())
println """
report \"$f.name\" created [size: ${f.size()/1024 as Integer} KB, path $f.path]
${((new Date().time - timer) / 1000)} seconds
"""
